package com.shujia.core.actions

import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.rdd.RDD

object foreachOpt {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf()
    conf.setMaster("local")
    conf.setAppName("union合并")

    val sc = new SparkContext(conf)

    val studentTupleRDD: RDD[(String, String, Int, String, String)] = sc.textFile("spark/data/students.txt")
      .map(_.split(",")) // [xxx,xxx,xx,xx,xxx]
      .map {
        case Array(id: String, name: String, age: String, gender: String, clazz: String) => (id, name, age.toInt, gender, clazz)
      }.repartition(2)

    println("hello world")
    studentTupleRDD.foreach(println)
    println("hello world2")
  }
}
